package UIFree.controls
{
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import flash.geom.Rectangle;

	public class uif_loaderBar extends uif_label {
		private var _percent: Number;
		public function uif_loaderBar(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			_percent = 0;
		}
		
		public function set percent(a_percent: Number) : void {
			if (a_percent > 100) a_percent = 100;
			else if (a_percent < 0) a_percent = 0;
			_percent = Math.round(a_percent);
			text = _percent + '%';
			this.repaint(styleClass);
		}

		override protected function paint(a_styleClass: String, a_method: String=''): void {
			var rect: Rectangle = getBorder();
			var style: Object = app.styleByName(a_styleClass);
			
			rect.width = _percent / 100 * rect.width;
			this.draw_rect(rect.x, rect.y, rect.width, rect.height, app.styleByName(style.barClass?style.barClass:'green'));
/*			rect = getBorder();
			this.draw_rect(rect.x, rect.y, rect.width, rect.height, app.styleByName(a_styleClass));*/
		}
	}
}